package lamdemom;

//无参数，无返回值
interface NoparameterNoReturn {
    void test();
}
//一个参数，无返回值
interface OneParameNoReturn {
    void test(int a);
}
//多个参数，无返回值
interface MoreParameNoReturn {
    void test(int a, int b);
}
//无参数，有返回值
interface NoParameReturn{
    int test();
}
//一个参数，有返回值
interface OneParameReturn{
    int test(int a);
}
//多个参数，有返回值
interface MoreParameReturn{
    int test(int a, int b);
}
public class Test {
    public static void main(String[] args) {
        MoreParameReturn moreParameReturn = new MoreParameReturn() {
            @Override
            public int test(int a, int b) {
                return a-b;
            }
        };
        MoreParameReturn moreParameReturn1 = (a,b) -> a+b;
        System.out.println(moreParameReturn.test(20,10));
        System.out.println(moreParameReturn1.test(20,10));
    }
    public static void main5(String[] args) {
        OneParameReturn oneParameReturn = new OneParameReturn() {
            @Override
            public int test(int a) {
                return a;
            }
        };
        System.out.println(oneParameReturn.test(10));
        OneParameReturn oneParameReturn1 =  a -> a-1;
        System.out.println(oneParameReturn1.test(20));
    }
    public static void main4(String[] args) {
        NoParameReturn noParameReturn = new NoParameReturn() {
            @Override
            public int test() {
                return 10;
            }
        };
        System.out.println(noParameReturn.test());
        NoParameReturn noParameReturn1 = ()-> 10;
        System.out.println(noParameReturn1.test());
    }
    public static void main3(String[] args) {
        MoreParameNoReturn moreParameNoReturn = new MoreParameNoReturn() {
            @Override
            public void test(int a, int b) {
                System.out.println("多个参数，无返回值:参数和: "+(a+b));
            }
        };
        int a = 0;
        int b = -1;
        moreParameNoReturn.test(a,b);
        MoreParameNoReturn moreParameNoReturn1 = (c,d) -> System.out.println("多个参数，无返回值:参数和: "+(c+d));
        moreParameNoReturn1.test(10,20);
    }
    public static void main2(String[] args) {
        OneParameNoReturn oneParameNoReturn = new OneParameNoReturn() {
            @Override
            public void test(int a) {
                System.out.println("一个参数+"+ a +"+，无返回值");
            }
        };
        int a = 10;
        oneParameNoReturn.test(a);
        OneParameNoReturn oneParameNoReturn1 = b -> System.out.println("一个参数+"+ b +"+，无返回值");
        oneParameNoReturn1.test(10);
    }
    public static void main1(String[] args) {
        NoparameterNoReturn noparameterNoReturn = new NoparameterNoReturn() {
            @Override
            public void test() {
                System.out.println("无参数，无返回值");
            }
        };
        NoparameterNoReturn noparameterNoReturn1 = ()->{
            System.out.println("无参数，无返回值");
        };
        noparameterNoReturn.test();
        noparameterNoReturn1.test();
    }
}
